﻿<%@ WebHandler Language="C#" Class="SyzyyHandler" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.Script.Serialization;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Xml;
using Dln.Common.Helper;
using Dln.Common;
using Dln.Model;
using Dln.Handler;
using Dln.Model.WebService.Model;
using Dos.ORM;
using Newtonsoft.Json;
using ServiceStack;
using Dln.Common.WxPayAPI;
using Dln.Business;

public class SyzyyHandler : HandlerBase
{
    public string url = CommonHelper.GetAppSettings("DlnService1");
    //public string url = "http://192.168.11.5:8080/Service1.asmx";

    /// <summary>
    /// 新增就诊人
    /// </summary>
    public void AddPatientInfo()
    {
        string openid = _httpReuqestString["openid"];
        string type = _httpReuqestString["type"];
        string name = _httpRequestForm["realName"];
        string idCard = _httpRequestForm["idCard"];
        string cardNo = _httpRequestForm["patientCard"];
        string phone = _httpRequestForm["phone"];

        //object[] arge = new object[4];
        //arge[0] = name;
        //arge[1] = idCard;
        //arge[2] = phone;
        //arge[3] = cardNo;

        //object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "AddPerson", arge);

        Dln.Common.ServiceReference1.Service1SoapClient client2 = new Dln.Common.ServiceReference1.Service1SoapClient();
        object getCurrInHospNum = client2.AddPerson(name, idCard, phone, cardNo);
        if (getCurrInHospNum != null)
        {
            string xml = "<outContent>" + getCurrInHospNum.ToString() + "</outContent>";
            XmlDocument x = new XmlDocument();
            x.LoadXml(xml);
            XmlNodeList nodeList = x.SelectNodes("outContent");
            string a = "";
            var result = nodeList[0].ChildNodes[0].InnerText;
            var message = nodeList[0].ChildNodes[1].InnerText;
            if (Convert.ToInt32(result) == 0)
            {
                PrintErrorJson(message);
            }
            else
            {
                var uptModel =
                    SqlHelper.Context.From<PatientInfo>()
                        .Where(d => d.PatientPatiID == cardNo && d.Delstatus == 0 && d.Openid == openid)
                        .First();
                var uptModel1 =
                    SqlHelper.Context.From<PatientInfo>()
                        .Where(d => d.PatientPatiID == cardNo && d.Delstatus == 1 && d.Openid == openid)
                        .First();
                if (type == "add")
                {
                    if (uptModel != null)
                    {
                        PrintErrorJson("添加失败，已存在该就诊人！");
                    }
                    if (uptModel1 != null)
                    {
                        uptModel1.Delstatus = 0;
                        uptModel1.PatientIdCard = idCard;
                        uptModel1.PatientPhone = phone;
                        uptModel1.PatientName = name;
                        uptModel1.PatientPatiID = cardNo;
                        uptModel1.Openid = openid;
                        var updateResult = SqlHelper.Context.Update<PatientInfo>(uptModel1);
                        if (updateResult > 0)
                        {
                            PrintSuccessJson("添加成功！");
                        }
                        else
                        {
                            PrintErrorJson("添加失败，请联系妇幼信息科！");
                        }
                    }

                    var model = new PatientInfo();
                    model.AddTime = DateTime.Now;
                    model.PatientIdCard = idCard;
                    model.PatientPhone = phone;
                    model.PatientName = name;
                    model.PatientPatiID = cardNo;
                    model.Openid = openid;
                    var insertResult = SqlHelper.Context.Insert<PatientInfo>(model);
                    if (insertResult > 0)
                    {
                        PrintSuccessJson("添加成功！");
                    }
                    else
                    {
                        PrintErrorJson("添加失败，请联系妇幼信息科！");
                    }
                }
                else
                {
                    uptModel.PatientIdCard = idCard;
                    uptModel.PatientPhone = phone;
                    uptModel.PatientName = name;
                    uptModel.PatientPatiID = cardNo;

                    var updateResult = SqlHelper.Context.Update<PatientInfo>(uptModel);
                    if (updateResult > 0)
                    {
                        PrintSuccessJson("修改成功！");
                    }
                    else
                    {
                        PrintErrorJson("修改失败，请联系妇幼信息科！");
                    }
                }


            }
        }
        PrintErrorJson("添加失败，请联系妇幼信息科！");
    }

    /// <summary>
    /// 删除就诊人
    /// </summary>
    public void DeletePatientInfo()
    {
        string openid = _httpReuqestString["openid"];
        string cardNo = _httpReuqestString["cardNo"];
        var delModel =
            SqlHelper.Context.From<PatientInfo>()
                .Where(d => d.PatientPatiID == cardNo && d.Delstatus == 0 && d.Openid == openid)
                .First();
        if (delModel != null)
        {
            delModel.Delstatus = 1;
            var updateResult = SqlHelper.Context.Update<PatientInfo>(delModel);
            if (updateResult > 0)
            {
                PrintSuccessJson("删除成功！");
            }
            else
            {
                PrintErrorJson("删除失败，请联系妇幼信息科！");
            }

        }
        PrintErrorJson("删除失败，未找到该就诊人信息！");
    }

    /// <summary>
    /// 查询住院费用
    /// </summary>
    public void SearchInHospitalMoney()
    {
        string name = _httpRequestForm["realName"];
        string cardNo = _httpRequestForm["patientCard"];

        object[] arge = new object[2];
        arge[0] = name;
        arge[1] = cardNo;

        object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "GetSubscription", arge);
        if (getCurrInHospNum != null)
        {
            var isExistReturn = getCurrInHospNum.ToString().Contains("return");
            if (isExistReturn)
            {
                string xml = "<outContent>" + getCurrInHospNum.ToString() + "</outContent>";
                XmlDocument x = new XmlDocument();
                x.LoadXml(xml);
                XmlNodeList nodeList = x.SelectNodes("outContent");
                string a = "";
                var message = nodeList[0].ChildNodes[1].InnerText;
                PrintErrorJson(message);
            }
            else
            {
                XmlDocument x = new XmlDocument();
                x.LoadXml(getCurrInHospNum.ToString());
                XmlNodeList nodeList = x.SelectNodes("table");
                string a = "";
                if (nodeList != null)
                {
                    var returnFirst = nodeList[0].ChildNodes[2].InnerText;
                    var returnSecond = nodeList[0].ChildNodes[3].InnerText;
                    PrintSuccessJson(string.Format("InHospitalMoneyList.aspx?returnFirst={0}&returnSecond={1}",
                        returnFirst, returnSecond));
                }
                PrintErrorJson("未查到该住院费用信息！");
            }

        }
    }

    /// <summary>
    /// 查询费用详细
    /// </summary>
    public void SearchInHospitalMoneyDetial()
    {
        string openid = _httpReuqestString["openid"];
        string cardNo = _httpReuqestString["cardNo"];
        string date = _httpReuqestString["date"];

        var model =
                SqlHelper.Context.From<PatientInfo>()
                    .Where(d => d.PatientPatiID == cardNo && d.Delstatus == 0 && d.Openid == openid)
                    .First();
        if (model != null)
        {
            object[] arge = new object[3];
            arge[0] = model.PatientName;
            arge[1] = cardNo;
            arge[2] = date;

            object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "GetADay", arge);
            if (getCurrInHospNum != null)
            {
                var isExistReturn = getCurrInHospNum.ToString().Contains("return");
                if (isExistReturn)
                {
                    string xml = "<outContent>" + getCurrInHospNum.ToString() + "</outContent>";
                    XmlDocument x = new XmlDocument();
                    x.LoadXml(xml);
                    XmlNodeList nodeList = x.SelectNodes("outContent");
                    string a = "";
                    var message = nodeList[0].ChildNodes[1].InnerText;
                    PrintErrorJson(message);
                }
                else
                {
                    XmlDocument x = new XmlDocument();
                    x.LoadXml(getCurrInHospNum.ToString());
                    XmlNodeList nodeList = x.SelectNodes("NewDataSet");
                    string a = "";
                    if (nodeList != null)
                    {
                        IList<GetADayModel> ModelList = new List<GetADayModel>();

                        for (var i = 0; i < nodeList[0].ChildNodes.Count; i++)
                        {
                            GetADayModel getADayModel = new GetADayModel();
                            getADayModel.ITEMID = nodeList[0].ChildNodes[i].ChildNodes[0].InnerText;
                            getADayModel.ITEMNAME = nodeList[0].ChildNodes[i].ChildNodes[1].InnerText;
                            getADayModel.UNITNAME = nodeList[0].ChildNodes[i].ChildNodes[2].InnerText;
                            getADayModel.UNITQUANTITY = Convert.ToDouble(nodeList[0].ChildNodes[i].ChildNodes[3].InnerText).ToString("0");
                            getADayModel.PRICE = Convert.ToDouble(nodeList[0].ChildNodes[i].ChildNodes[4].InnerText).ToString("F2");
                            getADayModel.TOTAMOUNT = Convert.ToDouble(nodeList[0].ChildNodes[i].ChildNodes[5].InnerText).ToString("F2");
                            getADayModel.BILLDATE = nodeList[0].ChildNodes[i].ChildNodes[6].InnerText;
                            ModelList.Add(getADayModel);
                        }
                        HttpContext.Current.Response.Write(JsonConvert.SerializeObject(ModelList));
                        HttpContext.Current.Response.End();
                    }

                }

            }
        }
    }

    /// <summary>
    /// 获取订单号（微信统一下单需要）
    /// </summary>
    public void GetPreOrderNo()
    {
        try
        {
            var realName = HttpContext.Current.Request.Form["realName"];
            var idCard = HttpContext.Current.Request.Form["idCard"];
            var phone = HttpContext.Current.Request.Form["phone"];

            string openid = _httpReuqestString["openid"];
            var randomNum = CommonHelper.GenRandomNumber(6);
            var ordNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + randomNum;

            //object[] arge = new object[3];
            //arge[0] = realName;
            //arge[1] = idCard;
            //arge[2] = phone;
            //object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "GetCardID", arge);

            Dln.Common.ServiceReference1.Service1SoapClient client2 = new Dln.Common.ServiceReference1.Service1SoapClient();
            object getCurrInHospNum = client2.GetCardID(realName, idCard, phone);

            if (getCurrInHospNum != null)
            {
                var isExistReturn = getCurrInHospNum.ToString().Contains("return");
                if (isExistReturn)
                {
                    string xml = "<outContent>" + getCurrInHospNum.ToString() + "</outContent>";
                    XmlDocument x = new XmlDocument();
                    x.LoadXml(xml);
                    XmlNodeList nodeList = x.SelectNodes("outContent");
                    var flag = nodeList[0].ChildNodes[0].InnerText;
                    if (flag == "0")
                    {
                        BuildCardRecord model = new BuildCardRecord();
                        model.PreOrderNo = ordNo;
                        model.AddTime = DateTime.Now;
                        model.OpenId = openid;
                        model.DelStatus = 0;
                        model.PatiName = realName;
                        model.PatiIdCard = idCard;
                        model.PatiPhone = phone;

                        var insertResult = SqlHelper.Context.Insert<BuildCardRecord>(model);
                        if (insertResult > 0)
                        {
                            PrintSuccessJson(ordNo);
                        }
                        else
                        {
                            PrintErrorJson("建卡失败，请联系医院信息科！");
                        }
                        //办卡

                    }
                    else if (flag == "1" || flag == "2" || flag == "3")
                    {
                        PrintErrorJson(nodeList[0].ChildNodes[1].InnerText);
                    }
                    else if (flag == "4")
                    {
                        var result = SqlHelper.Context.FromSql("update PatientInfo set Delstatus=1 where openid='" + openid + "'").ToScalar();

                        var model = new PatientInfo();
                        model.AddTime = DateTime.Now;
                        model.PatientIdCard = idCard;
                        model.PatientPhone = phone;
                        model.PatientName = realName;
                        model.PatientPatiID = nodeList[0].ChildNodes[1].InnerText;
                        model.Openid = openid;
                        model.Delstatus = 0;
                        var insertResult = SqlHelper.Context.Insert<PatientInfo>(model);
                        //已存在就诊卡
                        PrintSuccessJson("success");

                    }
                }
            }
        }
        catch (Exception ex)
        {
            var model = new PatientInfo();
            model.AddTime = DateTime.Now;
            model.PatientIdCard = "123";
            model.PatientPhone = "123";
            model.PatientName = "123";
            model.PatientPatiID = ex.ToString();
            model.Openid = "";
            model.Delstatus = 0;
            var insertResult = SqlHelper.Context.Insert<PatientInfo>(model);
        }
    }

    /// <summary>
    /// 新增就诊人
    /// </summary>
    public void CreateCardAddPatient()
    {
        string openid = _httpReuqestString["openid"];
        string name = _httpReuqestString["realName"];
        string idCard = _httpReuqestString["idCard"];
        string cardNo = _httpReuqestString["patientCard"];
        string phone = _httpReuqestString["phone"];

        var uptModel =
            SqlHelper.Context.From<PatientInfo>()
                .Where(d => d.PatientPatiID == cardNo && d.Delstatus == 0 && d.Openid == openid)
                .First();
        var uptModel1 =
            SqlHelper.Context.From<PatientInfo>()
                .Where(d => d.PatientPatiID == cardNo && d.Delstatus == 1 && d.Openid == openid)
                .First();

        if (uptModel != null)
        {
            PrintErrorJson("添加失败，已存在该就诊人！");
        }
        if (uptModel1 != null)
        {
            uptModel1.Delstatus = 0;
            uptModel1.PatientIdCard = idCard;
            uptModel1.PatientPhone = phone;
            uptModel1.PatientName = name;
            uptModel1.PatientPatiID = cardNo;
            uptModel1.Openid = openid;
            var updateResult = SqlHelper.Context.Update<PatientInfo>(uptModel1);
            if (updateResult > 0)
            {
                PrintSuccessJson("添加成功！");
            }
            else
            {
                PrintErrorJson("添加失败，请联系妇幼信息科！");
            }
        }

        var model = new PatientInfo();
        model.AddTime = DateTime.Now;
        model.PatientIdCard = idCard;
        model.PatientPhone = phone;
        model.PatientName = name;
        model.PatientPatiID = cardNo;
        model.Openid = openid;
        var insertResult = SqlHelper.Context.Insert<PatientInfo>(model);
        if (insertResult > 0)
        {
            PrintSuccessJson("添加成功！");
        }
        else
        {
            PrintErrorJson("添加失败，请联系妇幼信息科！");
        }

        PrintErrorJson("添加失败，请联系妇幼信息科！");
    }

    public void GetReportList()
    {
        string openid = _httpRequestForm["Openid"];
        PatientInfo Model = new PatientInfo();
        Model = SqlHelper.Context.From<PatientInfo>().Where(d => d.Openid == openid && d.Delstatus == 0).First();

        IList<ReportModel> ReportModelList = new List<ReportModel>();
        try
        {
            object[] arge = new object[2];
            arge[0] = Model.PatientPatiID;
            arge[1] = "2019-02-05";
            //object getCurrInHospNum = WebServiceHelper.InvokeWebService(url, "findAllReport", arge);
            Dln.Common.ServiceReference1.Service1SoapClient client2 = new Dln.Common.ServiceReference1.Service1SoapClient();
            object getCurrInHospNum = client2.findAllReport(Model.PatientPatiID, "2019-02-05");
            if (getCurrInHospNum != null)
            {
                XmlDocument x = new XmlDocument();
                x.LoadXml((getCurrInHospNum + "").Replace("&lt;", "<").Replace("&gt;", ">").Trim());


                XmlNodeList xnList = x.SelectNodes("//Table1");
                foreach (XmlNode xn in xnList)
                {
                    ReportModel reportModel = new ReportModel();
                    reportModel.PatiName = xn.ChildNodes[0].ChildNodes[0].ChildNodes[0].InnerText;
                    reportModel.SexName = xn.ChildNodes[0].ChildNodes[0].ChildNodes[1].InnerText;
                    reportModel.Age = Bright.Library.BO.Pub.BString.StrGetAgeFromBirthday(DateTime.Now, xn.ChildNodes[0].ChildNodes[0].ChildNodes[2].InnerText);
                    reportModel.ReportDate = (xn.SelectSingleNode("ApplyDate")).InnerText;

                    reportModel.ReportName = xn.ChildNodes[1].ChildNodes[0].ChildNodes[0].ChildNodes[1].InnerText;
                    reportModel.ReportName = CommonHelper.StringTruncat(reportModel.ReportName, 8, "...");
                    IList<ReportDetill> ReportDetillList = new List<ReportDetill>();

                    XmlNodeList xnListOut = xn.ChildNodes[2].ChildNodes[0].SelectNodes("row");
                    foreach (XmlNode xnItem in xnListOut)
                    {
                        ReportDetill reportDetillModel = new ReportDetill();
                        if (string.IsNullOrEmpty(xnItem.ChildNodes[0] + "")) continue;

                        reportDetillModel.SampleName = xnItem.ChildNodes[0].InnerText;
                        reportDetillModel.CurrentResult = xnItem.ChildNodes[1].InnerText;
                        reportDetillModel.ReportLimit = xnItem.ChildNodes[2].InnerText;
                        ReportDetillList.Add(reportDetillModel);
                    }
                    reportModel.ReportState = ReportDetillList.Count <= 0 ? "未出报告" : "已出报告";
                    reportModel.ReportDetillList = ReportDetillList;
                    ReportModelList.Add(reportModel);
                }
            }
        }
        catch
        {

        }

        HttpContext.Current.Response.Write(JsonConvert.SerializeObject(ReportModelList));
        HttpContext.Current.Response.End();
    }

    /// <summary>
    /// 获取医嘱列表
    /// </summary>
    public void GetOrdInfotoll()
    {
        string CardId = HttpContext.Current.Request.QueryString["CardId"];
        string PatiName = HttpContext.Current.Request.QueryString["PatiName"];

        Dln.Common.ServiceReference1.Service1SoapClient client2 = new Dln.Common.ServiceReference1.Service1SoapClient();
        object result = client2.GetOrdInfotoll(PatiName, CardId);
        if (result != null)
        {
            if (result.ToString().Contains("return"))
            {
                string xml = "<outContent>" + result.ToString() + "</outContent>";
                XmlDocument x = new XmlDocument();
                x.LoadXml(xml);
                XmlNodeList nodeList = x.SelectNodes("outContent");
                PrintErrorJson(nodeList[0].ChildNodes[1].InnerText);
            }
            else
            {
                var DataSets = JSONHelper.ConvertXMLToDataSet(result + "");
                if (DataSets.Tables.Count <= 0) PrintErrorJson("未获取到门诊待缴费记录！");
                var dc = DataSets.Tables[0];
                if (dc != null && dc.Rows.Count > 0)
                {
                    HttpContext.Current.Response.Write(SqlHelper.GetTablejson(dc));
                    HttpContext.Current.Response.End();
                }
                else
                {
                    PrintErrorJson("未获取到门诊待缴费记录！");
                }
            }
        }
        else
        {
            PrintErrorJson("未获取到门诊待缴费记录！");
        }
    }

    /// <summary>
    /// 获取门诊费用明细
    /// </summary>
    public void GetOrdInftollTwo()
    {
        string CardId = HttpContext.Current.Request.QueryString["CardId"];
        string PatiName = HttpContext.Current.Request.QueryString["PatiName"];
        string SerialnumberAndOrdID = HttpContext.Current.Request.QueryString["SerialnumberAndOrdID"];
        var SerialnumberAndOrdIDList = SerialnumberAndOrdID.Split('|');
        var OrdIds = "";
        if (SerialnumberAndOrdIDList.Length >= 2)
        {
            var OrdIDList = SerialnumberAndOrdIDList[1].Trim(',').Split(',');

            foreach (var item in OrdIDList)
            {
                OrdIds += item + "@";
            }
        }
        SerialnumberAndOrdID = SerialnumberAndOrdIDList[0] + "|" + OrdIds;

        Dln.Common.ServiceReference1.Service1SoapClient client2 = new Dln.Common.ServiceReference1.Service1SoapClient();
        object result = client2.GetOrdInftollTwo(CardId, PatiName, SerialnumberAndOrdID);
        if (result != null)
        {
            if (result.ToString().Contains("return"))
            {
                string xml = "<outContent>" + result.ToString() + "</outContent>";
                XmlDocument x = new XmlDocument();
                x.LoadXml(xml);
                XmlNodeList nodeList = x.SelectNodes("outContent");
                PrintErrorJson(nodeList[0].ChildNodes[1].InnerText);
            }
            else
            {
                var DataSets = JSONHelper.ConvertXMLToDataSet(result + "");
                var dc = DataSets.Tables[0];
                if (dc != null && dc.Rows.Count > 0)
                {
                    HttpContext.Current.Response.Write(SqlHelper.GetTablejson(dc));
                    HttpContext.Current.Response.End();
                }
                else
                {
                    PrintErrorJson("未获取到门诊待缴费记录！");
                }
            }
        }
        else
        {
            PrintErrorJson("未获取到门诊待缴费记录！");
        }

    }

    /// <summary>
    /// 门诊支付下单
    /// </summary>
    public void OutHospitalPreOrderNo()
    {
        string CardId = HttpContext.Current.Request.QueryString["CardId"];
        string PatiName = HttpContext.Current.Request.QueryString["PatiName"];
        string SerialnumberAndOrdID = HttpContext.Current.Request.QueryString["SerialnumberAndOrdID"];
        string OpenId = HttpContext.Current.Request.QueryString["OpenId"];
        decimal OrdMoney = Convert.ToDecimal(HttpContext.Current.Request.QueryString["OrdMoney"]);
        string visitTime = HttpContext.Current.Request.QueryString["visitTime"];
        string OrgName = HttpContext.Current.Request.QueryString["OrgName"];
        var randomNum = CommonHelper.GenRandomNumber(6);
        var ordNo = "EH" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + randomNum;

        BuildCardRecord model = new BuildCardRecord();
        model.PreOrderNo = ordNo;
        model.AddTime = DateTime.Now;
        model.OpenId = OpenId;
        model.DelStatus = 0;
        model.PatiName = PatiName;
        model.HISCardID = CardId;
        model.PatiIdCard = SerialnumberAndOrdID;
        model.HISOrgName = OrgName;
        model.HISTotalMoney = OrdMoney;
        model.HISOrdTime = string.IsNullOrEmpty(visitTime) ? Convert.ToDateTime("1990-01-01") : Convert.ToDateTime(visitTime);

        var insertResult = SqlHelper.Context.Insert<BuildCardRecord>(model);
        if (insertResult > 0)
        {
            string MainUrl = CommonHelper.GetAppSettings("mainurl");
            string APPID = CommonHelper.GetAppSettings("AppID");
            string time = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString();
            string noncestr = string.Empty, resp = string.Empty;

            string wxJsApiParam = ""; //H5调起JS API参数
            object ticket = null;
            string backUrl = "";


            noncestr = CommonHelper.RandString();
            time = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString();

            ticket = HttpContext.Current.Session["getticket"];
            if (ticket == null || ticket == "")
            {
                string newjson = RequestHelper.SendGet(String.Format("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi", WeiXinConfig.AccessToken));
                WinXinShareBusiness.GetTicket getticket = null;
                if (!String.IsNullOrEmpty(newjson))
                {
                    try
                    {
                        getticket = JSONHelper.FromJson<WinXinShareBusiness.GetTicket>(newjson);
                    }
                    catch (Exception ex)
                    {

                    }
                }
                ticket = getticket.ticket;
                HttpContext.Current.Session["getticket"] = ticket;
                HttpContext.Current.Session.Timeout = 20;
            }
            //string string1 = string.Format("jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}", ticket, noncestr, time, backUrl);
            //resp = CommonHelper.SHA1(string1);
            Log.Debug(this.GetType().ToString(), "Line28,code=" + "支付开始");

            //若传递了相关参数，则调统一下单接口，获得后续相关接口的入口参数
            JsApiPay jsApiPay = new JsApiPay { openid = OpenId, total_fee = Convert.ToInt32(OrdMoney * 100) };
            //JSAPI支付预处理
            try
            {
                WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(ordNo);
                wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数        
                Log.Debug(this.GetType().ToString(), "wxJsApiParam:" + wxJsApiParam.Replace("\"", "'"));
                PrintSuccessJson(wxJsApiParam.Replace("\"", "'"));
            }
            catch (System.Threading.ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                Log.Debug(this.GetType().ToString(), "微信支付失败:" + ex.ToString());
                PrintErrorJson("微信支付失败:" + ex.ToString());
            }
        }
        else
        {
            PrintErrorJson("支付失败，获取订单号错误");
        }
    }

    /// <summary>
    /// 获取缴费历史
    /// </summary>
    public void GetOrdInfotollHistory()
    {
        string OpenId = HttpContext.Current.Request.QueryString["OpenId"];
        //var BuildCardRecordList = SqlHelper.Context.From<BuildCardRecord>().Where(d => d.OpenId == OpenId && d.PayNo != null && d.PayNo != "" && d.PreOrderNo.Substring(0, 2) == "EH").ToList();
        var BuildCardRecordList = SqlHelper.Context.FromSql(@" select * from BuildCardRecord  where PayNo !='' and PayNo is not null and openid='orrZmw6biSbZglMMLFS4eB81nycM' and PreOrderNo like'EH%'").ToList<BuildCardRecord>();
        if (BuildCardRecordList != null && BuildCardRecordList.Count > 0)
        {
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(BuildCardRecordList));
            HttpContext.Current.Response.End();
        }
        else
        {
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(new List<BuildCardRecord>()));
            HttpContext.Current.Response.End();
        }

    }
}